<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileGetShortcut</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileGetShortcut</h1>

<p>Retrieves information about a shortcut (.lnk) file, such as its target file.</p>

<pre class="Syntax">FileGetShortcut, LinkFile [, OutTarget, OutDir, OutArgs, OutDescription, OutIcon, OutIconNum, OutRunState]</pre>
<h3>Parameters</h3>
<dl>

  <dt>LinkFile</dt>
  <dd><p>Name of the shortcut file to be analyzed, which is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. Be sure to include the <strong>.lnk</strong> extension.</p></dd>

  <dt>OutTarget</dt>
  <dd><p>Name of the variable in which to store the shortcut's target (not including any arguments it might have). For example: C:\WINDOWS\system32\notepad.exe</p></dd>

  <dt>OutDir</dt>
  <dd><p>Name of the variable in which to store the shortcut's working directory. For example: C:\My Documents. If environment variables such as %WinDir% are present in the string, one way to resolve them is via <a href="StringReplace.htm">StringReplace</a>. For example: <code>StringReplace, OutDir, OutDir, `%WinDir`%, %<a href="../Variables.htm#WinDir">A_WinDir</a>%</code>.</p></dd>

  <dt>OutArgs</dt>
  <dd><p>Name of the variable in which to store the shortcut's parameters (blank if none).</p></dd>

  <dt>OutDescription</dt>
  <dd><p>Name of the variable in which to store the shortcut's comments (blank if none).</p></dd>

  <dt>OutIcon</dt>
  <dd><p>Name of the variable in which to store the filename of the shortcut's icon (blank if none).</p></dd>

  <dt>OutIconNum</dt>
  <dd><p>Name of the variable in which to store the shortcut's icon number within the icon file (blank if none). This value is most often 1, which means the first icon.</p></dd>

  <dt>OutRunState</dt>
  <dd><p>Name of the variable in which to store the shortcut's initial launch state, which is one of the following digits:</p>
    <p>1:  Normal<br>
      3: Maximized <br>
        7: Minimized<br>
    </p></dd>

</dl>
<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p>If there was a problem -- such as <em>LinkFile</em> not existing -- all the output variables are made blank and <a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1. Otherwise, ErrorLevel is set to 0.</p>
<h3>Remarks</h3>
<p>Any of the output variables may be omitted if the corresponding information is not needed.</p>
<h3>Related</h3>
<p><a href="FileCreateShortcut.htm">FileCreateShortcut</a>, <a href="SplitPath.htm">SplitPath</a></p>
<h3>Example</h3>
<pre class="NoIndent">FileSelectFile, file, 32,, Pick a shortcut to analyze., Shortcuts (*.lnk)
if file =
    return
FileGetShortcut, %file%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState
MsgBox %OutTarget%`n%OutDir%`n%OutArgs%`n%OutDesc%`n%OutIcon%`n%OutIconNum%`n%OutRunState%</pre>

</body>
</html>
